package cn.com.api.mapper.base;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.*;

import cn.com.api.entity.ApiU_link;

//DAO
public interface U_linkMapperBase {

	// 根据id查看
	@Select("SELECT * FROM u_link  WHERE id = #{id}")
	public ApiU_link findU_linkById(Integer id);

	// 查看数据集
	@Select("SELECT u.*,g.name groupname FROM U_link u left join u_link_group g on u.group_id = g.id")
	public List<ApiU_link> findU_links();

	@Select("SELECT u.*,g.name groupname FROM U_link u left join u_link_group g on u.group_id = g.id where u.group_id = #{groupid} order by u.sort asc")
	public List<ApiU_link> findU_linksByGroupId(Integer groupid);

	// 添加
	@Insert("INSERT INTO u_link (name, group_id, url, is_effect, sort, img, description, count, show_index, ext_1, ext_2, ext_3, ext_4, ext_5) VALUES (#{name}, #{group_id}, #{url}, #{is_effect}, #{sort}, #{img}, #{description}, #{count}, #{show_index}, #{ext_1}, #{ext_2}, #{ext_3}, #{ext_4}, #{ext_5})")
	@Options(useGeneratedKeys = true, keyProperty = "id")
	public int insertU_link(ApiU_link u_link);

	// 修改
	@Update("UPDATE u_link SET name = #{name}, group_id = #{group_id}, url = #{url}, is_effect = #{is_effect}, sort = #{sort}, img = #{img}, description = #{description}, count = #{count}, show_index = #{show_index}, ext_1 = #{ext_1}, ext_2 = #{ext_2}, ext_3 = #{ext_3}, ext_4 = #{ext_4}, ext_5 = #{ext_5} WHERE id = #{id}")
	public int updateU_link(ApiU_link u_link);

	// 删除
	@Delete("DELETE FROM u_link  WHERE id = #{id}")
	public int deleteU_link(Integer id);

	// Foreign keys revelant

	// region Indexs revelant

}
